package com.distributer.timer.model;

import java.io.Serializable;
import java.util.concurrent.atomic.AtomicBoolean;

public class ScheduledTask implements Serializable {
	
    private static final long serialVersionUID = 1L;

    /**
    * id
    */
    private Integer id;

    /**
    * 任务key值（使用bean名称）
    */
    private String taskKey;

    /**
    * 任务描述
    */
    private String taskDesc;

    /**
    * 请求地址
    */
    private String requestUrl;

    /**
    * 任务表达式
    */
    private String taskCron;

    /**
    * 程序初始化是否启动 1 是 0 否
    */
    private Integer initStartFlag;

    private AtomicBoolean isStop = new AtomicBoolean(false);

    public ScheduledTask() {
    }

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getTaskKey() {
		return taskKey;
	}

	public void setTaskKey(String taskKey) {
		this.taskKey = taskKey;
	}

	public String getTaskDesc() {
		return taskDesc;
	}

	public void setTaskDesc(String taskDesc) {
		this.taskDesc = taskDesc;
	}

	public String getRequestUrl() {
		return requestUrl;
	}

	public void setRequestUrl(String requestUrl) {
		this.requestUrl = requestUrl;
	}

	public String getTaskCron() {
		return taskCron;
	}

	public void setTaskCron(String taskCron) {
		this.taskCron = taskCron;
	}

	public Integer getInitStartFlag() {
		return initStartFlag;
	}

	public void setInitStartFlag(Integer initStartFlag) {
		this.initStartFlag = initStartFlag;
	}
	
	public void updateTaskToStop(){
		this.isStop.set(true);
	}
	
	public void updateTaskToStart(){
		this.isStop.set(false);
	}
	
	public boolean isStop(){
		return isStop.get();
	}
}
